import type { IQuery, IResponse, TableResponse } from '@/api/config/types';
import type { STATUS_ENUM } from '@/enum/system';
import axios from 'axios';

const prefix = '/system/role';

export interface SystemRole {
  roleName: string;
  roleKey: string;
  roleSort: number;
  dataScope: string;
  menuCheckStrictly: boolean;
  deptCheckStrictly: boolean;
  status: STATUS_ENUM;
  createBy?: any;
  createTime: string;
  updateBy?: any;
  updateTime?: any;
  remark: string;
  params: any;
  flag: boolean;
  menuIds: any[];
  deptIds?: any;
  admin: boolean;
  roleId: string;
}

// 查询角色列表
export const listRole = (query?: IQuery) => {
  return axios.get<IResponse<SystemRole[]>>(`${prefix}/list`, { params: query });
};

// 新增角色
export const addRole = (data: SystemRole) => {
  return axios.post<IResponse>(`${prefix}`, data);
};

// 删除角色
export const delRole = (roleId: (string | number)[]) => {
  return axios.delete<IResponse>(`${prefix}/${roleId}`);
};

// 修改角色
export const updateRole = (data: SystemRole) => {
  return axios.put<IResponse>(`${prefix}`, data);
};

// 查询角色详细
export const getRole = (roleId: string) => {
  return axios.get<IResponse<SystemRole>>(`${prefix}/${roleId}`);
};
interface RoleMenuTreeselect {
  checkedKeys: any[];
}
export function roleMenuTreeselect(roleId: string) {
  return axios.get<IResponse<RoleMenuTreeselect>>(`/system/menu/roleMenuTreeselect/${roleId}`);
}
